import request from '../utils/request'
// import store from '@/store'
// 登录
export const login = data => {
  return request({
    method: 'POST',
    url: '/v1_0/authorizations',
    data: data
  })
}

// 发送验证码
export const sendSms = phoneNum => {
  return request({
    method: 'GET',
    url: `/v1_0/sms/codes/${phoneNum}`
  })
}

// 请求用户数据
export const getUserInfo = () => {
  return request({
    method: 'GET',
    url: '/v1_0/user'
  })
}

// 获取自己的个人资料
export const getOwnProfile = () => {
  return request({
    method: 'GET',
    url: '/v1_0/user/profile'
  })
}

// 修改个人资料
export const editUserProfile = (data) => {
  return request({
    method: 'PATCH',
    url: '/v1_0/user/profile',
    data
  })
}

// 修改头像图片
export const editUserPhoto = (data) => {
  return request({
    method: 'PATCH',
    url: '/v1_0/user/photo',
    data
  })
}

// 请求频道列表
export const getUserChannels = () => {
  return request({
    method: 'GET',
    url: '/v1_0/user/channels'
  })
}

// 关注用户
export const addFollow = (target) => {
  return request({
    method: 'POST',
    url: '/v1_0/user/followings',
    data: {
      target // 要关注的用户id
    }
  })
}

// 取消关注
export const deleteFollow = (target) => {
  return request({
    method: 'DELETE',
    url: `v1_0/user/followings/${target}`
  })
}

// 获取指定用户信息
export const getChoiceUserInfo = (target) => {
  return request({
    method: 'GET',
    url: `/v1_0/users/${target}`
  })
}

// 我的收藏
export const myCollectArticle = () => {
  return request({
    method: 'GET',
    url: '/v1_0/article/collections'
  })
}

// 获取用户阅读历史
export const getUserHistories = (target) => {
  return request({
    method: 'GET',
    url: '/v1_0/user/histories'
  })
}
